package org.zjx.analysis.analyze.association;

import lombok.Getter;
import org.zjx.analysis.analyze.window.AbstractWindowAnalyzer;
import org.zjx.analysis.identify.IdentifyTessUtil;
import org.zjx.command.entity.ParagraphBean;
import org.zjx.command.enums.FontType;
import org.zjx.command.util.ImageUtil;
import org.zjx.window.window.IWindow;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Arrays;
import java.util.List;

@Getter
public class AssociationPurchaseAnalysis extends AbstractWindowAnalyzer {
    private int chamberNumber; // 选中的店铺号码
    private int chooseNumber; // 选中的店铺页面编号
    private List<ParagraphBean.Word> words;
    private String choosePetName;
    private int money;
    private int cash;

    public AssociationPurchaseAnalysis(IWindow window) {
        super("宠物界面", "商会", window);
    }


    private String choosePetName() {
        for (ParagraphBean.Word word : words) {
            Rectangle rectangle = word.getRectangle();
            BufferedImage image = ImageUtil.cutImage(screenshot, rectangle);
            if (ImageUtil.haveColor(image, Arrays.asList(new Color(93, 91, 228), new Color(167, 172, 114)))) {
                return word.getName();
            }
        }
        return null;
    }

    public Rectangle getPetArea(String petName) {
        for (ParagraphBean.Word word : words) {
            if (word.getName().equals(petName)) {
                return word.getRectangle();
            }
        }
        return null;
    }

    public Rectangle getBuyButtonArea() {
        return conversion(windowArea,areaMap.get("购买").getRectangle());
    }

    private int analysisChooseNumber() {
        for (int i = 0; i < 10; i++) {
            ResolutionImage resolutionImage = imageMap.get("数字" + (i + 1) + "选中按钮");
            Rectangle rectangle = new Rectangle(resolutionImage.getRectangle().x - 2, resolutionImage.getRectangle().y - 2, resolutionImage.getRectangle().width + 4, resolutionImage.getRectangle().height + 4);
            rectangle = conversion(windowArea, rectangle);
            BufferedImage bufferedImage = ImageUtil.cutImage(screenshot, rectangle);
            List<Point> points = ImageUtil.matchTemplate(bufferedImage, resolutionImage.getPattern());
            if (!points.isEmpty()) {
                return i;
            }
        }
        return -1;
    }

    public Rectangle getPageButton(int pageNumber) {
        return conversion(windowArea, imageMap.get("数字" + pageNumber + "选中按钮").getRectangle());
    }

    @Override
    protected void initResources() {
        areaMap.put("店铺号码", new ResolutionArea(ImageUtil.createRect(226, 52, 254, 66)));

        areaMap.put("上翻", new ResolutionArea(ImageUtil.createRect(266, 102, 276, 113)));
        areaMap.put("下翻", new ResolutionArea(ImageUtil.createRect(266, 289, 276, 300)));
        areaMap.put("购买", new ResolutionArea(ImageUtil.createRect(194, 397, 231, 414)));
        areaMap.put("离开", new ResolutionArea(ImageUtil.createRect(241, 397, 278, 414)));

        areaMap.put("总价", new ResolutionArea(ImageUtil.createRect(112, 345, 171, 359)));
        areaMap.put("现金", new ResolutionArea(ImageUtil.createRect(109, 367, 206, 384)));
        areaMap.put("内容", new ResolutionArea(ImageUtil.createRect(18, 102, 196, 299)));
        areaMap.put("滚动", new ResolutionArea(ImageUtil.createRect(264, 116, 278, 287)));

        imageMap.put("数字1选中按钮", new ResolutionImage(ImageUtil.createRect(14, 313, 29, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABE0lEQVR42q2UPWvCYBSF7+jo0CGDSIYO76CQocMLdsgo1CGIgmOHLoKDbv6Ejv0JXZ26lSKKHyBIQ7euiRVa/Bm356a6eV+JNfCEA+eeZ0sobA25/vDIvo244AVMVwYECia7kVvZyJYkFEoWRU6wkS0Z2/kTlMKcWJYtFf2Q/8MlBHV2Ua42M7SeitcICrW7Lsvz8rpUb8jD6xiN9oAPz3i6Zu2OPIPgINl883i2VnsIInaRbH4giNWevAqCg+QLgnms9uTj5SKFYAKB1pMfIDhItxAsYrWHoMMu0u0Ogg+1J3OD4GD1/snPo7ejXfYt2EafRXIOsqWo98Tm9j6z5QIb2ZL8FCTYqL8XnQA3cisb2f4CsGLrB93GxuoAAAAASUVORK5CYII=")));
        imageMap.put("数字2选中按钮", new ResolutionImage(ImageUtil.createRect(36, 313, 51, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABRElEQVR42mNwCKn475HS8V/BIuA/h4TBfwYRDSA2wIE1wGpAakF6QHoZQAwOGQugBIkYqAekl0HDIgJigIwDidjiP0gvg4CCw39KMDUM8PiPCwsqev6398n5b+OZiVMNg4AKkIEFe0YU/0cHhk6JGOoYJIAENgwC23YdBbPltHz/v//w+f+z568x1DFIaAAZaFjbMhxsgIyON1xswfItYDF0tUADAv5jw/J6oXC2tmUcWPPsRZsx1DFI6AAZeLCJWypY8827j7HKMygACVzYO7QIrHnvwdM41TAoGAAZWLB3BETzsrU7/+NSA8JAAyL+o2M1s1h41JU3zoTjoPg6DLUMGiZABhq29s35jw1cvfkARR04L1j4FPwHGUIOBullCMiZ8F/DJgFsGkkYqAeklwFUKIAYFgEFUIMIYKAakFqQHpBeAMerCB/89zUdAAAAAElFTkSuQmCC")));
        imageMap.put("数字3选中按钮", new ResolutionImage(ImageUtil.createRect(58, 313, 73, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABU0lEQVR42mNwCKn475HS8V/BIuA/h4TBfwYRDSA2wIE1wGpAakF6QHoZQAwOGQugBIkYqAekl0HDIgJigIwDidjiP0gvg4CCw39KMDUM8PiPC4ur+f53DSz4b+SQhFMNg4AKkIEF51T2/0cHpm4pGOoYJIAENgwCsxdsALM1TUL/v37z/v/bdx8x1DFIaAAZWPCshetR+Ou27Acbiq4OaEDAf1w4MLb6/5adx/6/AdoMAkm5HRhqGCR0gAwcuLxpBlwzCHhHl2OoYVAAEsTgvQdPgw1BF2dQMAAy0HBiTvP/d+8/oYiV1k+GGICmFmhAxH90bO+bD1a8aOXO/27BJf+zSyeA+U+fv8FQy6BhAmRgwQW1U1DSwNFTV/5r2cajqAHnBQufgv8gQ8jBIL0MATkT/mvYJIBNIwkD9YD0MoAKBRDDIqAAahABDFQDUgvSA9ILAIyqDZBWREDjAAAAAElFTkSuQmCC")));
        imageMap.put("数字4选中按钮", new ResolutionImage(ImageUtil.createRect(80, 313, 95, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABLUlEQVR42mNwCKn475HS8V/BIuA/h4TBfwYRDSA2wIE1wGpAakF6QHoZQAwOGQugBIkYqAekl0HDIgJigIwDidjiP0gvg4CCw39KMDUM8PhPCIup+f7XsojBKscgoAJkEMDXbj34DwLY5BgkgAQ+nFPc9R8GsMkzSGgAGTiwmmnwf2SATQ3QgID/uPCV6/fAGrsnL4cagKmGQUIHyMCCM0p7wZpsfLP/d0+FGoBFHYMCkEDHakahYA3nLt78H5FY83/LjiNgvr1nBoZaBgUDIAMNGzvG/8cG7j98hqEWaEDEf0K4f/pqsAHY5Bg0TIAMAriyddb/Dx+/YIiD84KFT8F/kCHkYJBehoCcCf81bBLAppGEgXpAehlAhQKIYRFQADWIAAaqAakF6QHpBQCLIQTrEVcOqAAAAABJRU5ErkJggg==")));
        imageMap.put("数字5选中按钮", new ResolutionImage(ImageUtil.createRect(102, 313, 117, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABPUlEQVR42mNwCKn475HS8V/BIuA/h4TBfwYRDSA2wIE1wGpAakF6QHoZQAwOGQugBIkYqAekl0HDIgJigIwDidjiP0gvg4CCw39KMDUM8PhPCWYQUAEysGBsILeyH0MdgwSQwIZBoLlr7n9Th3gwNraNxaqOQUIDyMCCQSCvoud/elH7/8Scpv9yur5Y1QENCPiPDWMDKsaRGOoYJHSADCwYBLqnLgez5Y1CwfzFq3diqGNQABLYsIF1LAr/+KnL/+8/fIahjkHBAMjAgjsmLPyvaBgI5z9/+eb/8dOXMdQBDYj4jw2DwOVr9/57R1T87568AsyPSGnCUMegYQJkYMHhaY0oAdjUtwhDDTgvWPgU/AcZQg4G6WUIyJnwX8MmAWwaSRioB6SXAVQogBgWAQVQgwhgoBqQWpAekF4AxdgKqEGmoKIAAAAASUVORK5CYII=")));
        imageMap.put("数字6选中按钮", new ResolutionImage(ImageUtil.createRect(124, 313, 139, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABaUlEQVR42mNwCKn475HS8V/BIuA/h4TBfwYRDSA2wIE1wGpAakF6QHoZQAwOGQugBIkYqAekl0HDIgJigIwDidjiP0gvg4CCw39KMDUM8PiPD9t4Zv43dUrBKc8goAJkYMEGTon/0YGiSSiGOgYJIIENP3768v/HT1/+K2j7/Vc1CAIbMGXmKgx1DBIaQAYWDALRabX/FfT9/muYh/w3tI8B0+jqgAYE/EfHGuYxYAOePHsNd/63bz/+KxlFYKhlkNABMtCwsUsKXKOJW+p/fUdIeGzYfhhDLYMCkEDH+lYQF9h5ZMDF1mzc9//7958YahkUDIAMLBgEEnKa4Pzjpy//v//wGYY6oAER/7HhG7cfgQ3xDCv7X1o/A8wua5iBoY5BwwTIwIL1nZL/v33/CR4W85Zvx1ADzgsWPgX/QYaQg0F6GQJyJvzXsEkAm0YSBuoB6WUAFQoghkVAAdQgAhioBqQWpAekFwDGHRGAkncWAgAAAABJRU5ErkJggg==")));
        imageMap.put("数字7选中按钮", new ResolutionImage(ImageUtil.createRect(146, 313, 161, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABDUlEQVR42q2UMYrCYBCFp7S0sEhhkUKWX7SIoPgHFjZlQIUUSmKjFhbCWshu455gBRuXBS+g4B1sPMAeanZmtFInEjXwhQfzvtclEHTnGI4X6NoIc46HUDCEp2Ckw1122AUOuaKlQ0bIYReMTY4DxSAjFtmFvBvgIzxjIMRHgHyJwhlh/Inac94Fh17XqDYTbARDYbXeidwbzC964BgKKVT8WOTl7+bqnQYiTGN/+JMB7Q5OlUIK/Hz/bNU7uPTSeKl1ZaDV+1A74HoUFN46Exko21jt0ECCGu3+lwykdcDUKSj4rffjgHKXb8G2Z8gj98AuRNMVmteRrGWCHHaBfwocbDQ7Dd2AOtxlh91/DYvxAe8P3UgAAAAASUVORK5CYII=")));
        imageMap.put("数字8选中按钮", new ResolutionImage(ImageUtil.createRect(168, 313, 183, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABYklEQVR42mNwCKn475HS8V/BIuA/h4TBfwYRDSA2wIE1wGpAakF6QHoZQAwOGQugBIkYqAekl0HDIgJigIwDidjiP0gvg4CCw39KMDUM8PiPC4uoeP+3887+r2sdh1MNg4AKkIEFR6TV/0cG33/8/C+u5YuhjkECSGDDILBx60EwW8c8AsyfNmcNhjoGCQ0gAwsGge7Ji1H4azfvw1AHNCDgPzY8dc46sKZrNx/8//v3L5ht7JiCoY5BQgfIwIJ3HTgN1vTsxRt4OPjFVmKoY1AAEujYwjkZrCE2tQEudvb8jf9fvn7HUMugYABkoGHPsAKwAWqmIXCxKXNWg8XQ1QINiPiPDYPA+cu3/7sFl/xPL+oF87fsOo6hjkHDBMjAggMTa1HSweGTl/4rmkaiqAHnBQufgv8gQ8jBIL0MATkT/mvYJIBNIwkD9YD0MoAKBRDDIqAAahABDFQDUgvSA9ILALq4F7Ry/09FAAAAAElFTkSuQmCC")));
        imageMap.put("数字9选中按钮", new ResolutionImage(ImageUtil.createRect(190, 313, 205, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABZ0lEQVR42mNwCKn475HS8V/BIuA/h4TBfwYRDSA2wIE1wGpAakF6QHoZQAwOGQugBIkYqAekl0HDIgJigIwDidjiP0gvg4CCw39KMDUM8PiPD1u4pv3XtY7DKc8goAJkYMEe4cX/kcHVm/exqmOQABLYMAicPHMFzLZwSgTzCyv7MdQxSGgAGWhYXs8XrMHRLxMudvz05f8XrtzCUAs0IOA/OlY0DAcb4ORfABfbd/jc/5+/fmOoZZDQATKwYBD49v3n/6T8jv/b954A8//9+4ehjkEBSGDDFs7J/588ewXW+PrNh/+Pn778/+rNewx1DAoGQAYWXN8x67+uTRSc/+PHz/9bdh3BUAc0IOI/NgwCt+8++e/gV/C/f/pqMN8nshJDHYOGCZCBBbuGlaCkg55pKzHUgPOChU/Bf5Ah5GCQXoaAnAn/NWwSwKaRhIF6QHoZQIUCiGERUAA1iAAGqgGpBekB6QUAktMTmWR8770AAAAASUVORK5CYII=")));
        imageMap.put("数字10选中按钮", new ResolutionImage(ImageUtil.createRect(212, 313, 227, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABs0lEQVR42q2UTyhEURTG79LSwmIW0ltIr5gaop6oebERQ0PUZDGI1GAxyoKFLJQoxVopKUoWogyJ/EthmpL8yeLNIP8KhSyZ45yD231KGtz6vc757vd9m9d7wqzuhJKmftAMLyQ5XCBSdMT1DTp7yEsZygoaklINvEgQzFBW6IbvvSDVTBADKCuSNRP+wn8UlIBKmrOK+aoTbk8bOAv8Nk0kp+PwQUFZAOjMhDZA1bOLGkA9+0eWvBMOfBCemnZpWFrZhk+duL65g3g8DlpmBZRWB9nT3jXEd8Kho0nBil3A0uq2TaPT0jEg99PzKzg4tnjGAi+oWLFLLAjLPcds5IK84mapTc+usUazcGShqGCdYsFaWO6F5a1szsivldroxPx7Ac5Cw4dKFAuWseBzz3XXsdksDUhtbmETXl5eeRaaC0WF6BkWrIdtGp2e/hG5Pz49w07kkGcs8IFK9OwaCyI2LbJ3wiWV/m7oHRzn2R/o4zuh56JJYWv3AMamFm2a090At/cP8jWPToZY52/B8ASBSn4DZYW3bRj0wnpuSwjMUFbQT4EGwxv8KPoB9JCXMpR9AxqAMrU3F4vCAAAAAElFTkSuQmCC")));

        imageMap.put("数字1未选中按钮", new ResolutionImage(ImageUtil.createRect(14, 313, 29, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAAu0lEQVR42mMIyOj4n9Gy4b9Hxoz/DhEd/y1C8GOQGpBakB6QXgaPnAUENeHCIL0MFhETyDYApJeBbM1QDDSg4T8u7BzXDsb41DBYBAAZWHB0/rT/ILDnyJX/uNSAMFYDUsvn/IeBw6dvkm4ADD96+mZkGOADZODAYANO3vyPTw3lBhj4VPzHhU9euPN/+eZj//GpwWsAIQzxAjA9k20AKC84JEwg2wCQXgYDjwIgYwYkdxHlbIjNID0gvQAdLmcGE8JTxgAAAABJRU5ErkJggg==")));
        imageMap.put("数字2未选中按钮", new ResolutionImage(ImageUtil.createRect(36, 313, 51, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABFklEQVR42mMIyOj4n9Gy4b9Hxoz/DhEd/y1C8GOQGpBakB6QXgaPnAUENeHCIL0MFhETyDYApJeBbM1QDDSg4T82bBna8D++bOb/mOLp/3GpAWEGiwAgAw2nV877jw5CMib+x6YWqwEgcODEdTDbNqT5/8fP3/6/evOROAM84rrABlgHN8HF1m4/DRYj2gV2oc0YBq7cfIJ4A2A4ILUfrPn+41c41eA0IL5oBljzkdM3/+OzhMHCB8hAw/H5EM0bdpz5j00eGWMYYBfYDI+6tkkb4Ti1ZA52Awx8Kv4jY8+kjv/YwI17z/6jqwVhBmyCxGKIF4DpmWwDQHnBIWEC2QaA9DIYeBQAGTMguYsoZ0NsBukB6QUATOZ/L7mffd4AAAAASUVORK5CYII=")));
        imageMap.put("数字3未选中按钮", new ResolutionImage(ImageUtil.createRect(58, 313, 73, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABJElEQVR42mMIyOj4n9Gy4b9Hxoz/DhEd/y1C8GOQGpBakB6QXgaPnAUENeHCIL0MFhETyDYApJeBbM1QDDSg4T82bBfZ/D+las7/kJxJ/3GpAWEGiwAgAw23Ttn4Hx2EZ0/+j00tVgNAYOXmE2C2W2zn/3cfvvz/8Okr8Qas2HQchb/z0CWwoUQbAMKZ1fP/7z927f/7j1/Bmis6VpBmQNeMLXDNIJBSPoc0A5DxkdM38XjBB8hAwkUNS/9/ANqMLNYyYQPEADS1IIxhQEjqRLDiNVtO/Y/Kmvq/umMVmP/i1QfsBhj4VPxHx1U9K1DSwMkLd/5bhtT9x6YWqwHEYogXgOmZbANAecEhYQLZBoD0Mhh4FAAZMyC5iyhnQ2wG6QHpBQCx+oNrNuMkJgAAAABJRU5ErkJggg==")));
        imageMap.put("数字4未选中按钮", new ResolutionImage(ImageUtil.createRect(80, 313, 95, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAA8klEQVR42mMIyOj4n9Gy4b9Hxoz/DhEd/y1C8GOQGpBakB6QXgaPnAUENeHCIL0MFhETyDYApJeBbM1QDDSg4T8+bBvR/N83rRenPINFAJCBB999+PI/COCSx2tAQ/+6/zBAsgEuUe3/kQHJBty69xyscfby/aQbUNu7BqwpPHsy6QbYhTaDNVy5+fh/Vs2C/3uOXAHzQzIm4jDAB8hAwp7RXf+xgcdP3/5HVwvCDNgEkfHspVAv4JBnMPCp+I8PN01e9//j52845QkagA9DvABMz2QbAMoLDgkTyDYApJfBwKMAyJgByV1EORtiM0gPSC8Awc58PvYrDgEAAAAASUVORK5CYII=")));
        imageMap.put("数字5未选中按钮", new ResolutionImage(ImageUtil.createRect(102, 313, 117, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABCElEQVR42mMIyOj4n9Gy4b9Hxoz/DhEd/y1C8GOQGpBakB6QXgaPnAUENeHCIL0MFhETyDYApJeBbM1QDDSg4T8lmMEiAMhAw9hA25SN/7GpxWnAlIW7/wemTQBj/5Q+rJrxGtA0cf3/mp7V/8vbV/y3DWkm3QB04BTZRpoBs5fvB7PtQpvB/A07zxBvgFtsJwr/7OX7/x8/e4vDAB8gAw1Pmb/7v6Uvgv/qzcf/Zy/d/49NLVYDQODGnWf/4/Nn/J+xaC+Yn1W5ALsBBj4V/9FxcsVMlADsnr3lPzZ1IMyAS4IYDPECMD2TbQAoLzgkTCDbAJBeBgOPAiBjBiR3EeVsiM0gPSC9AO80gPpGzAbbAAAAAElFTkSuQmCC")));
        imageMap.put("数字6未选中按钮", new ResolutionImage(ImageUtil.createRect(124, 313, 139, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABL0lEQVR42mMIyOj4n9Gy4b9Hxoz/DhEd/y1C8GOQGpBakB6QXgaPnAUENeHCIL0MFhETyDYApJeBbM1QDDSg4T8uHFM8/X943uT/+NQwWAQAGWg4OGPif3TgFtv5H5tarAY8f/Xh/+cv3//bh7X8d45qBxuweN0R4g0AgcKmJWAD3GI6/vsm94JpogwAKQSBF68/wJ3//cev/44RrcQZ4J/SB9cYkNr/3yexB8zeffgyaS4ABSRMbOu+C/9//PyFwwAfIAMNg8OgYQmcf/bS/f+Pn779j00tVgPuPHgJNiQmd/r/lgkbwOzWiRuxG2DgU/EfHdtFNP5/9/ELPCyWbjz6H5s6EGbAJUEMhngBmJ7JNgCUFxwSJpBtAEgvg4FHAZAxA5K7iHI2xGaQHpBeAD7PhpGzURJyAAAAAElFTkSuQmCC")));
        imageMap.put("数字7未选中按钮", new ResolutionImage(ImageUtil.createRect(146, 313, 161, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAA6ElEQVR42mMIyOj4n9Gy4b9Hxoz/DhEd/y1C8GOQGpBakB6QXgaPnAUENeHCIL0MFhETyDYApJeBbM1QDDSg4T8lmMEiAMhAwmmVc//jAuhqQZgBm6BnfPf/wLQJYDx/9SGw5ty6hcQbAMMecV1gzbOX78epBq8Bh0/fxOl0ogwAgRlL9pJngG1IM9iA+KIZBAzwATKw4JDUiWADHIJb/+NSA8I4DYjPnwnxPx7NYAMMfCr+Y8PuCe1gA3DJwzADIQX4MMQLwPRMtgGgvOCQMIFsA0B6GQw8CoCMGZDcRZSzITaD9ID0AgCUomuDEIiuPQAAAABJRU5ErkJggg==")));
        imageMap.put("数字8未选中按钮", new ResolutionImage(ImageUtil.createRect(168, 313, 183, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABL0lEQVR42mMIyOj4n9Gy4b9Hxoz/DhEd/y1C8GOQGpBakB6QXgaPnAUENeHCIL0MFhETyDYApJeBbM1QDDSg4T82bB3e9D++dMb/gMz+/7jUgDCDRQCQgYZLWpb9RwY/fv7+bxfa/B+bWqwGgMCeI1fAbM/4bjB/6YajpBkwe/l+FP6Og5eIN2DxuiNgTXcevPj/9+8/MNs/pY94Aw6fvgnW9OrNR3g4pFXOJc4A3+ResIa8hkVwsUs3Hv3/+v0nDgN8gAwkHJM7HWyAbUAzXGz+ykNgMXS1IMyATRAErt588j8qa+r/itYVkFg5fAW7AQY+Ff/RcVzJNJR0cPz87f+GvpX/sanFagCxGOIFYHom2wBQXnBImEC2ASC9DAYeBUDGDEjuIsrZEJtBekB6AUAii5+wtlpcAAAAAElFTkSuQmCC")));
        imageMap.put("数字9未选中按钮", new ResolutionImage(ImageUtil.createRect(190, 313, 205, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABN0lEQVR42mMIyOj4n9Gy4b9Hxoz/DhEd/y1C8GOQGpBakB6QXgaPnAUENeHCIL0MFhETyDYApJeBbM1QDDSg4T8uHFkw9X9AZv9/fGoYLAKADDScVjn3PzK48/Dlf2zqQBirASBw8dpDMDskYyKY3zplI3EG2IU2gzVE50+Di52/+uD/9TtPiTPAIbwVbEBMwXS42PFzt///+v2HNC/8+Pnrf0XHiv8HT1wH8//9+0e8Ab7Jvf+fv/oA1vjuw5f/z16+///2/WccBvgAGWi4d8a2/85h7XD+j5+//+85fOU/NrVYDQCB+49e/Q9Jm/R/9tL9YH58/kzsBhj4VPxHx0FZfSjpYMrinf+xqQNhBlwSxGCIF4DpmWwDQHnBIWEC2QaA9DIYeBQAGTMguYsoZ0NsBukB6QUACnaISrdTcj4AAAAASUVORK5CYII=")));
        imageMap.put("数字10未选中按钮", new ResolutionImage(ImageUtil.createRect(212, 313, 227, 330), ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAABXUlEQVR42mMIyOj4n9Gy4b9Hxoz/DhEd/y1C8GOQGpBakB6QXgaPnAUENeHCIL0MFhETyDYApJeBbM1QDDSg4T8MO8e1gzGyGAzHl838H5DZjyHOYBEAZABxdP60/yCw58iV/zAxEA7JmPgfGdy69xxFHmxAavkcuILDp2+iKHj19tP/f//+/bcPa/mfXDYbrKZ1ykZUA2D40dM3GAaAQH3fWjj/yfN3KK7Aa4Bfch/YgMC0CXCx7QcugsWIMiA8ezJYsUtUO1xs1daTxBvgGd8NVhySOQkutvvw5f9//v5FMsAHyIBisAEnb/5HFgOB3hnb4PxPX77/P3/lAZxP0IBL1x+BDUkpmfN/4pwdYHZ+7WKEAQY+Ff9h+OSFO/+Xbz72H1nMJqz+/9v3n+HRvGTjERR5FANIxRAvANMz2QaA8oJDwgSyDQDpZTDwKAAyZkByF1HOhtgM0gPSCwDIQ6GTRmLBtAAAAABJRU5ErkJggg==")));

    }

    @Override
    public Rectangle closeArea() {
        return ImageUtil.createRect(277, 5, 286, 14);
    }

    @Override
    public Rectangle getOriginBounds() {
        return ImageUtil.createRect(253, 86, 545, 511);
    }

    @Override
    public Rectangle getRefImageArea() {
        return ImageUtil.createRect(13, 76, 40, 89);
    }

    @Override
    public BufferedImage getRefImage() {
        return ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAABwAAAAOCAYAAAA8E3wEAAAB7klEQVR42mMQkFD4jw3XN3f89/AL+Y9LHhsWllb+H5OUjlcNg4SBxf+QtJz/s5as+D976Uo4hgFkMRCetnDpf1Ub5/8gfejY3CcYrGf6omVY5UGYAWQrDDx7/gKO37x5+//rt28oYiD84OGj/7om1mDX7j94+P+1GzdRMAygi2/ZthPhQxBIKalEccnC1ev+f/z0GadLQXjx2g3/dwEtRcYwgC4+Y/EyVB/GpWSihPXyVWvB4iAaGS9dsfq/jrEVzji6c/ce2Ed44xCbD1dt3gYWf/7qFQp+AgxWj+hEnL6+CwzyG3fuEo5DbD788+cP3hQnIqPy3z80+n9wZBwcf/v2/f+nz59RxHyCIv4LSiqi+jA2r+R/ZFbB/8MnT/8/ef4iPC5AbBgGxYWxhz/ctaHpuf+JBa4R8ag+9AuJgkseB1qKDYPAwcNH8fqaYBwqmNuDDbILigTTGRW1OMN/39Hj/y8DDcOXcgnGISh8QUBcXg1MJ2fk4nTdnn0H/l+6fJUyH05dsBhsESwuJ8yZ/1/b0RMrfvD4yf8LV6+D1SpaOPwvaWr/X9HWhYJB4N+/fxjipcCiElRCMRw5duL/mXPnwbafOHWGYOSXVzeA1bp6B/4nFQSGx/5nkDS0/A/CsDAGsWWARRc2jC/uiMUAdSCV8dnNkCUAAAAASUVORK5CYII=");
    }

    @Override
    public void analyze(BufferedImage image) {

        this.chamberNumber = Integer.parseInt(identifyTess(areaMap.get("店铺号码")));
        this.money = Integer.parseInt(identifyTess(areaMap.get("总价")));
        this.cash = Integer.parseInt(identifyTess(areaMap.get("现金")));
        this.chooseNumber = analysisChooseNumber() + 1;

        words = identifyFont(areaMap.get("内容").getRectangle(), Arrays.asList(new Color(184, 180, 224), new Color(93, 91, 228)), FontType.LIN, 0, true);
        this.choosePetName = choosePetName();
    }

    private String identifyTess(ResolutionArea resolutionArea) {
        Rectangle rectangle = conversion(windowArea,resolutionArea.getRectangle());
        BufferedImage bufferedImage = ImageUtil.cutImage(screenshot,rectangle);
        return IdentifyTessUtil.tessIdentify(bufferedImage);
    }
}
